<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>公寓管理系统 - 房屋信息管理</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/lib/font-awesome/css/font-awesome.css">
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

</head>
<body>
<div class="box">
    <h3>房屋信息管理</h3>
    <div class="actions">
        <div>
            <a class="btn btn-primary" href="${pageContext.request.contextPath}/view/rent/add.jsp">添加房屋信息</a>
            <form action="${pageContext.request.contextPath}/rent/findAll?pageNo=1" method="post">
                <select id="sele" name="sele">
                    <option value="hfloor">根据楼层查找</option>
                    <option value="haddress">根据地址查询</option>
                    <%--                <option value="cc">根据地址查询</option>--%>
                    <%--                <option value="dd">根据地址查询</option>--%>
                    <%--                <option value="ee">根据地址查询</option>--%>
                    <%--                <option value="ff">根据地址查询</option>--%>
                </select>
                请输入值<input id="inp" name="val" type="text">
                <input id="sub" type="submit" value=" 提交">
            </form>
        </div>
    </div>

    <table class="list">
        <tr>
            <th>租户号</th>
<%--       lessee     --%>
            <th>租户姓名</th>
            <th>手机号</th>
            <th>性别</th>
            <th>籍贯</th>
            <th>身份证号</th>
<%--         house   --%>
            <th>房屋地址</th>
            <th>面积</th>
            <th>出租价格(元)</th>
            <th>出租状态</th>
            <th>是否双气</th>
<%--            rent--%>
            <th>缴纳房租</th>

            <th>操作</th>
        </tr>
        <c:forEach var="p" items="${list}">
        <tr>
            <td>${p.rid}</td>

            <td>${p.lessee.lname}</td>
            <td>${p.lessee.ltel}</td>
            <td>${p.lessee.lsex==1 ? '男' : '女'}</td>
            <td>${p.lessee.lnp}</td>
            <td>${p.lessee.lidCard}</td>

            <td>${p.house.haddress}</td>
            <td>${p.house.harea}</td>
            <td>${p.house.hprice}</td>
            <td>${p.house.hrentStatus==1 ? '已出租' :(p.house.hrentStatus==2 ? '未出租':'暂停出租' )}</td>
            <td>${p.house.hair==1?'有双气':'无双气'}</td>
<%--            已出租,未出租,暂停出租--%>
            <td>${p.rprice}</td>
            <td>
                <a class="fa fa-info" title="详情" href="${pageContext.request.contextPath}/rent/findById?rid=${p.rid}&a=1"></a>
                &nbsp;&nbsp;
                <a class="fa fa-pencil" title="编辑" href="${pageContext.request.contextPath}/rent/findById?rid=${p.rid}&a=2"></a>
                &nbsp;&nbsp;
                <a class="fa fa-remove" title="删除" href="#" onclick="confirmDelete(1)"></a>
            </td>
        </tr>
        </c:forEach>
    </table>
    <div class="pager-info">
        <div>共有 ${total}条记录，第 ${pageNo}/${pageCount} 页 </div>
        <div>
            <ul class="pagination">
                <c:if test="${pageNo!=1}">
                    <li class="paginate_button previous disabled }">
                        <a href="${pageContext.request.contextPath}/rent/findAll?pageNo=${pageNo-1}&sele=${sele}&val=${val}">上一页</a>

                    </li>
                </c:if>
                <c:forEach begin="1" end="${pageCount}" var="index">
                    <c:if test="${pageNo==index}">
                        <li id="li" class="paginate_button active"><a href="${pageContext.request.contextPath}/rent/findAll?pageNo=${index}&sele=${sele}&val=${val}">${index}</a></li>
                    </c:if>
                    <c:if test="${pageNo!=index}">
                        <li id="li" class="paginate_button"><a href="${pageContext.request.contextPath}/rent/findAll?pageNo=${index}&sele=${sele}&val=${val}">${index}</a></li>
                    </c:if>
                </c:forEach>

                <c:if test="${pageNo!=pageCount}">
                <li class="paginate_button next disabled">
                    <a  href="${pageContext.request.contextPath}/rent/findAll?pageNo=${pageNo+1}&sele=${sele}&val=${val}">下一页</a>
                </li>
                </c:if>
            </ul>
        </div>
    </div>
</div>
<script type="text/javascript">
    var sele;
    var val;
</script>
<script src="${pageContext.request.contextPath}/lib/jquery/jquery.js"></script>
<script>
    function confirmDelete(id){
        if (confirm("确定要删除码？")) {
            alert('发送删除请求，刷新页面（不要异步）');
        }
        return false;
    }
</script>
</body>
</html>